﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProfManager;
using System.IO;

namespace ProfileManagerTest
{
    public partial class Form1 : Form
    {
        ProfileManager pMan;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            pMan = new ProfileManager("ProfileManagerTest", false, true, "Settings.ini", "OtherFile.txt");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //use INI?
            if (radioButton1.Checked)
            {
                pMan.writeINIValue(0, "Default", textBox1.Text, textBox2.Text);
            }
            else
            {
                pMan.AppendTextToProfileFile(1, textBox1.Text + ":" + textBox2.Text);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (radioButton4.Checked)
            {
                textBox3.Text = pMan.readINIValue(0, "Default", textBox4.Text);
            }
            else
            {
                StreamReader SR = pMan.GetProfileFile(1);
                string s = "";
                while ((s = SR.ReadLine()) != null)
                {
                    if (s.StartsWith(textBox4.Text + ":"))
                    {
                        textBox3.Text = s.Substring(s.IndexOf(":")+1);
                    }
                }
                SR.Close();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pMan.PromptForUser();
        }
    }
}
